package view;

import java.util.ArrayList;
import java.util.Random;

import model.Data;
import model.domain.Student;

public class PrintView {
	private static Data d = new Data();
	
	public static void printView(Object msg) {
		System.out.println(msg);
	}//end of printView
	
	public static void printViewSTU(Student stu){
		System.out.println("["+stu.getNumber() + ". " + stu.getName()+"] ");
	}//end of printViewSTU
	
	public static void printViewSTU(Student stu, int size){
		int num=1;
		for(int i=0; i<size; i++){
			System.out.println("[Group #"+(++num)+"]");
			System.out.print("["+stu.getNumber() + ". " + stu.getName()+"] ");
		}
	}//end of printViewSTU @overloading
	
	public static void printViewAll(ArrayList all){
		Student s = new Student();
		for(int i =0; i<all.size(); i++){
			s = (Student) all.get(i);
			printViewSTU(s);
		}
	}//end of printViewAll
	
	public static void printSM(ArrayList<String> all,int row, int col){
		ArrayList<String> name = new ArrayList<String>();
		for(int i=0; i<all.size(); i++){
			for(int j=0; j<all.size(); j++){
				if(all.get(i).equals(d.dataAll().get(j).getNumber()))
						name.add(d.dataAll().get(j).getName());
			}
		}
		for(int k=0;k<name.size(); k++){
			System.out.print(name.get(k));
			if(k % 2 == 0) System.out.print("-");
			if(k % 2 == 1) System.out.print("\t");
			if((k+1) % (row*2) == 0) System.out.println();
		}
		System.out.println();
	}//end of printSM
	
	public static void printSM(ArrayList<String> all,int size){
		ArrayList<String> name = new ArrayList<String>();
		boolean p = true;
		
		for(int i=0; i<all.size(); i++){
			for(int j=0; j<all.size(); j++){
				if(all.get(i).equals(d.dataAll().get(j).getNumber()))
						name.add(d.dataAll().get(j).getName());
				//System.out.println("i : "+i+", j : "+d.dataAll().get(j).getNumber());
			}
		}
		int h=1;
		for(int k=0;k<name.size(); k++){
			if(p){ System.out.print("[Group #"+(h++)+"] ");	p=false;}
			System.out.print(name.get(k) + "\t");
			if((k+1) % size == 0){ System.out.println(); p=true;}
		}
		System.out.println();	
	}//end of printSM
}
